
<%@page import="com.kucun.bean.Users"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 Users user=(Users)request.getSession().getAttribute("user");
%>
<script type="text/javascript">
function HashMap(){  
      //定义长度  
      var length = 0;  
      //创建一个对象  
      var obj = new Object();  
    
      /** 
      * 判断Map是否为空 
      */  
      this.isEmpty = function(){  
          return length == 0;  
      };  
    
      /** 
      * 判断对象中是否包含给定Key 
      */  
      this.containsKey=function(key){  
          return (key in obj);  
      };  
    
      /** 
      * 判断对象中是否包含给定的Value 
      */  
      this.containsValue=function(value){  
          for(var key in obj){  
              if(obj[key] == value){  
                  return true;  
              }  
          }  
          return false;  
      };  
    
      /** 
      *向map中添加数据 
      */  
      this.put=function(key,value){  
          if(!this.containsKey(key)){  
              length++;  
          }  
          obj[key] = value;  
      };  
    
      /** 
      * 根据给定的Key获得Value 
      */  
      this.get=function(key){  
          return this.containsKey(key)?obj[key]:null;  
      };  
    
      /** 
      * 根据给定的Key删除一个值 
      */  
      this.remove=function(key){  
          if(this.containsKey(key)&&(delete obj[key])){  
              length--;  
          }  
      };  
    
      /** 
      * 获得Map中的所有Value 
      */  
      this.values=function(){  
          var _values= new Array();  
          for(var key in obj){  
              _values.push(obj[key]);  
          }  
          return _values;  
      };  
    
      /** 
      * 获得Map中的所有Key 
      */  
      this.keySet=function(){  
          var _keys = new Array();  
          for(var key in obj){  
              _keys.push(key);  
          }  
          return _keys;  
      };  
    
      /** 
      * 获得Map的长度 
      */  
      this.size = function(){  
          return length;  
      };  
          /** 
      * 清空Map 
      */  
      this.clear = function(){      
          length = 0;  
          obj = new Object();  
      };  
      /** 新增三个方法 **/  
      /**
 	  * 通过value获取key
 	  */
       this.getKeyByValue=function(value){  
           for(var key in obj){  
               if(obj[key] == value){  
                   return key;  
               }  
           }  
           return null;  
       };  
 	  /**
 	  * 通过value移除key
 	  */	  
 	  this.removeByValue = function(value){
 	  	if(this.getKeyByValue(value))
 			delete obj[this.getKeyByValue(value)];	  
 	  };
 	   /**
 	   * 通过key和value获取新title	   
 	   */
 	  this.getNameByName = function(tKey , url){
 		var thisKey = null;
 		if((thisKey = this.getKeyByValue(url))!= null)
 			return thisKey;		
 		if(!this.containsKey(tKey)){
				this.put(tKey,url);
				return tKey;
		}
 		var num = this.size();
 		for(var i=1;i<=num;i++){ 			
 			var tName = tKey +"("+i+")";
 			if(!this.containsKey(tName)){
 				this.put(tName,url);
 				return tName;
 			}			
 		}
 	  };
  }  
</script>
<script type="text/javascript" charset="UTF-8">
var mapurl=  new HashMap();
	var index_tabs;
	var index_tabsMenu;
	$(function() {
		
		index_tabs = $('#centerTabs').tabs({
			border : false,
			fit : true,
			onContextMenu : function(e, title) {
				e.preventDefault();
				index_tabsMenu.menu('show', {
					left : e.pageX,
					top : e.pageY
				}).data('tabTitle', title);
			},
			onSelect: function(title,index){
		     //  alert(title);
	        }
			//tabPosition:'right',
			//tabWidth:40,
			//headerWidth:250
		});
		
		index_tabsMenu = $('#index_tabsMenu').menu({
			onClick : function(item) {
				
				var curTabTitle = $(this).data('tabTitle');
				var type = $(item.target).attr('title');

				if (type === 'refresh') {
				     //alert(curTabTitle)
				     var currTab = $('#centerTabs').tabs('getTab', curTabTitle);
		             var iframe = $(currTab.panel('options').content);
		             var src = iframe.attr('src');
		             var id = iframe.attr('id');
				     document.getElementById(id).src=src;
				     //self.parent.$('#centerTabs').tabs('update', { tab: currTab, options: { content: createFrame(src)} });		
					return;
				}

				if (type === 'close') {
					var t = index_tabs.tabs('getTab', curTabTitle);
					if (t.panel('options').closable) {
						index_tabs.tabs('close', curTabTitle);
					}
					return;
				}

				var allTabs = index_tabs.tabs('tabs');
				var closeTabsTitle = [];

				$.each(allTabs, function() {
					var opt = $(this).panel('options');
					if (opt.closable && opt.title != curTabTitle && type === 'closeOther') {
						closeTabsTitle.push(opt.title);
					} else if (opt.closable && type === 'closeAll') {
						closeTabsTitle.push(opt.title);
					}
				});

				for ( var i = 0; i < closeTabsTitle.length; i++) {
					index_tabs.tabs('close', closeTabsTitle[i]);
				}
			}
		});
		window.setTimeout(function(){
			<%
				
				if(null!=user){
					%>
					var src = '<%=basePath%>page/loginuserinformation.jsp';
					index_tabs.tabs('add', {
						title : '个人信息',
						content : '<iframe src="' + src + '" frameborder="0" style="border:0;width:100%;height:99.2%;"></iframe>',
						closable : false,
						iconCls : ''
					});
					<%
				}
			%>
			
		}, 800);

	});
	
	
/* function createFrame(url) {
    var s = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
    return s;
} */
</script>
<div id="centerTabs"  class="easyui-tabs" fit="true"></div>
<div id="index_tabsMenu" style="width: 120px; display: none;">
	<div title="refresh" data-options="iconCls:'icon-reload'">刷新</div>
	<div class="menu-sep"></div> 
	<div title="close" data-options="iconCls:'icon-no'">关闭</div>
	<div class="menu-sep"></div>
	<div title="closeOther" data-options="iconCls:'icon-no'">关闭其他</div>
	<div class="menu-sep"></div>
	<div title="closeAll" data-options="iconCls:'icon-cancel'">关闭所有</div>
</div>
